/**
 * 
 */
package com.wkr.teachertask;
import java.util.Scanner;

/**   
 * @ClassName:  DevelopTask   
 * @Description:TODO(if/for循环的扩展作业)   
 * @author: WuKangrong 
 * @date:   2018年7月21日 上午10:16:01     
 * @Copyright: 2018 
 */
public class DevelopTaskIfAndFor {

	/**   
	 * @Title: main   
	 * @Description: TODO(入口)   
	 * @param: @param args      
	 * @return: void      
	 * @throws   
	 */
	public static void main(String[] args) {
		inputControl();
	}
	
	/**   
	 * @Title: inputControl   
	 * @Description: TODO(输入交互)   
	 * @param:       
	 * @return: void      
	 * @throws   
	 */
	static void inputControl()
	{
		Scanner input = new Scanner(System.in);
		int in_Num = 0;
		System.out.println("请输入棱形的行数：");
		in_Num = input.nextInt();
		drawStar(in_Num);
		System.out.println("请输入镂空棱形的行数：");
		in_Num = input.nextInt();
		drawStar_3(in_Num);
		System.out.println("请输入等腰三角形的行数：");
		in_Num = input.nextInt();
		drawStar_1(in_Num);
		System.out.println("请输入镂空等腰三角形的行数：");
		in_Num = input.nextInt();
		drawStar_2(in_Num);
	}
	
	/**   
	 * @Title: drawStar   
	 * @Description: TODO(打印棱形)   
	 * @param: @param in_Num      
	 * @return: void      
	 * @throws   
	 */
	static void drawStar(int in_Num)
	{
		/**
		 * @param in_Num 是输入值
		 * @param star_Begin 是*开始的位置
		 * @param star_End 是*结束的位置
		 * @param star_Mid  *最中间那一列的的位置也是最中间那一行的位置
		 * @param move_Flag 是用来标记当前y_Int 位置
		 */
		int in_Number = in_Num;
		int star_Mid = in_Number / 2 + 1;
		int star_Begin = star_Mid;
		int star_End = star_Mid;
		int move_Flag = 0;
		
		/**
		 * x_Int是X轴的位置，y_Int是Y轴的位置
		 */
		for(int x_Int = 1; x_Int <= in_Number; x_Int++) {
			for(int y_Int = 1; y_Int <= in_Number; y_Int++) {
				//打印出上三角，从第一行到最中间那行的操作如下
				if(x_Int <= star_Mid) {
					//*开始的位置是最中间那一列的位置  当y_Int到了*开始的位置
					if(y_Int == star_Begin ){
						//move_Flag 标记Y轴位置，=*开始的位置
						move_Flag = star_Begin;
						//当Y轴位置在 star_Begin 和 star_End 之间就输出* 
						while(move_Flag <= star_End) {
							System.out.print("*");
							//Y轴位置要右移
							move_Flag++;
						}
						//打印完一行后*开始和就是位置要向两边变化 就是扩张
						star_Begin--;
						star_End++;
						/**
						 * 上三角执行完最后一次循环后star_Begin和star_End会超出范围，所以先 +/- 1，再 +/-1 是为了直接进行下三角输出
						 */
						if(x_Int == star_Mid) {
							star_Begin += 2;
							star_End -= 2;
						}
						break;
					}else {
						System.out.print(" ");
					}
				}else {//这一部分是下三角输出 同上的意思
					if (y_Int == star_Begin){
						move_Flag = star_Begin;
						while (move_Flag <= star_End) {
							System.out.print("*");
							move_Flag++;
						}
						star_Begin++;
						star_End--;
						break;
					}else {
						System.out.print(" ");
					}
				}
			}
			System.out.println();
		}
	}
	
	/**   
	 * @Title: drawStar_1   
	 * @Description: TODO(打印等腰三角形)   
	 * @param: @param in_Num      
	 * @return: void      
	 * @throws   
	 */
	static void drawStar_1(int in_Num)
	{
		int in_Number = in_Num;
		//int star_Mid = in_Number / 2 + 1;
		int star_Begin = in_Num;
		int star_End = in_Num;
		int move_Flag = 0;
		
		for(int x_Int = 1; x_Int <= in_Number; x_Int++) {
			for(int y_Int = 1; y_Int < 2 * in_Number; y_Int++) {
					if(y_Int == star_Begin ){
						move_Flag = star_Begin;
						while(move_Flag <= star_End) {
							System.out.print("*");
							move_Flag++;
						}
						star_Begin--;
						star_End++;
						break;
					}else {
						System.out.print(" ");
					}
			}
			System.out.println();
		}
	}
	
	/**   
	 * @Title: drawStar_2   
	 * @Description: TODO(打印镂空等腰三角形)   
	 * @param: @param in_Num      
	 * @return: void      
	 * @throws   
	 */
	static void drawStar_2(int in_Num)
	{
		int in_Number = in_Num;
		//int star_Mid = in_Number / 2 + 1;
		int star_Begin = in_Num;
		int star_End = in_Num;
		int move_Flag = 0;
		
		for(int x_Int = 1; x_Int <= in_Number; x_Int++) {
			for(int y_Int = 1; y_Int < 2 * in_Number; y_Int++) {
					/**
					 * 最后一行完整输出
					 */
					if(x_Int == in_Number) {
						move_Flag = star_Begin;
						if(y_Int == star_Begin ) {
							while(move_Flag <= star_End) {
								System.out.print("*");
								move_Flag++;
							}
						}	
					}else if(y_Int == star_Begin ){//不是最后一行的要求，镂空
						move_Flag = star_Begin;
						while(move_Flag <= star_End) {
							if(move_Flag == star_Begin) {
								System.out.print("*");
								move_Flag++;
							}else if(move_Flag == star_End) {
								System.out.print("*");
								move_Flag++;
							}else {
								System.out.print(" ");
								move_Flag++;
							}
						}
						star_Begin--;
						star_End++;
						break;
					}else {
						System.out.print(" ");
					}
			}
			System.out.println();
		}
	}
	
	/**   
	 * @Title: drawStar_3   
	 * @Description: TODO(镂空棱形)   
	 * @param: @param in_Num      
	 * @return: void      
	 * @throws   
	 */
	static void drawStar_3(int in_Num)
	{
		int in_Number = in_Num;
		int star_Mid = in_Number / 2 + 1;
		int star_Begin = star_Mid;
		int star_End = star_Mid;
		int move_Flag = 0;
		
		for(int x_Int = 1; x_Int <= in_Number; x_Int++) {
			for(int y_Int = 1; y_Int <= in_Number; y_Int++) {
				if(x_Int <= star_Mid) {
					if(y_Int == star_Begin ){
						move_Flag = star_Begin;
						while(move_Flag <= star_End) {
							if(move_Flag == star_Begin) {
								System.out.print("*");
								move_Flag++;
							}else if(move_Flag == star_End) {
								System.out.print("*");
								move_Flag++;
							}else {
								System.out.print(" ");
								move_Flag++;
							}
						}
						star_Begin--;
						star_End++;
						/**
						 * 上三角执行完最后一次循环后star_Begin和star_End会超出范围，所以先 +/- 1，再 +/-1 是为了直接进行下三角输出
						 */
						if(x_Int == star_Mid) {
							star_Begin += 2;
							star_End -= 2;
						}
						break;
					}else {
						System.out.print(" ");
					}
				}else {
					if (y_Int == star_Begin){
						move_Flag = star_Begin;
						while (move_Flag <= star_End) {
							if(move_Flag == star_Begin) {
								System.out.print("*");
								move_Flag++;
							}else if(move_Flag == star_End) {
								System.out.print("*");
								move_Flag++;
							}else {
								System.out.print(" ");
								move_Flag++;
							}
						}
						star_Begin++;
						star_End--;
						break;
					}else {
						System.out.print(" ");
					}
				}
			}
			System.out.println();
		}
	}
}
